# Contributor: Leon ROUX <leon.roux@federate.us>
# Maintainer: Leon ROUX <leon.roux@federate.us>
pkgname=supercollider
pkgver=3.12.2
pkgrel=2
pkgdesc="An audio server, programming language, and IDE for sound synthesis and algorithmic composition."
url="https://supercollider.github.io/"
arch="x86_64 x86 aarch64 armv7" # blocked by qt5-qtwebengine
license="GPL-3.0-or-later"
depends="git"
makedepends="
	alsa-lib-dev
	boost-dev
	boost-static
	cmake
	eudev-dev
	fftw-dev
	jack-dev
	libsndfile-dev
	libxt-dev
	linux-headers
	ncurses-dev
	portaudio-dev
	qt5-qtbase-dev
	qt5-qtdeclarative-dev
	qt5-qtsvg-dev
	qt5-qttools-dev
	qt5-qtwebengine-dev
	qt5-qtwebsockets-dev
	readline-dev
	samurai
	yaml-cpp-dev
	"
checkdepends="xvfb-run"
subpackages="$pkgname-dev"
source="https://github.com/supercollider/supercollider/releases/download/Version-$pkgver/SuperCollider-$pkgver-Source.tar.bz2
	00-fortified-headers.patch
	sndfile.patch
	"
builddir="$srcdir/SuperCollider-$pkgver-Source"

export LDFLAGS="$LDFLAGS -Wl,-z,stack-size=2000000"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DFORTIFY=ON \
		-DSYSTEM_BOOST=ON \
		-DSYSTEM_YAMLCPP=ON \
		-DSYSTEM_PORTAUDIO=ON \
		-DSC_ABLETON_LINK=OFF \
		-DNATIVE=OFF \
		-DSC_EL=OFF
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE xvfb-run ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
ad2466047353b65879f2acd9ba6b6f429010af08ef3f1150adebb93927244f4337aeb09d5aa6cc4cd26b091bc101488eebf822d21c177de55f0f8f7c2a31eb7c  SuperCollider-3.12.2-Source.tar.bz2
cef3e1bdaecd4278d14fcabc39d2a69cfab1216ff3dedd3e54997470955dd310e502732ff2c0f76e95f349c31deb964eff456f49f51d7e3c83421521d0c30c43  00-fortified-headers.patch
92b98c220d7a5b2ab246fa47ff4945493812019f16b0fed27b1d009ed8f7b5270bfbc91e2f0dd98706de86e52cc4f9920db2af341c0d632d30f3a2a487e3a1d7  sndfile.patch
"
